﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mirror.Models
{
    public class ProvidersDownloader
    {
        private List<Provider> _providers;

        private static ProvidersDownloader _instance = null;

        public static ProvidersDownloader Instance
        {
            get
            {
                if (_instance == null) _instance = new ProvidersDownloader();
                return _instance;
            }
        }

        private ProvidersDownloader()
        {
            _providers = XmlManager.XmlManager.DeserializeFromAddress<List<Provider>>("http://vps-1113939-12744.manage.myhosting.com/indicator/indicator.php?c=4f95710bd4a971776e5eefdbdaf5ff6c");
        }

        public Symbol GetSymbol(String Provider, String Symbol)
        {
            foreach (Provider p in _providers)
            {
                if (p.Name == Provider)
                {
                    return p.GetSymbol(Symbol);
                }
            }

            return null;
        }
    }
}
